﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using KeRui.Common;
using System.Collections.Generic;

public partial class Manage_Cms_CommentList : System.Web.UI.Page
{
    protected List<KeRui.Model.CmsComment> listCmsComment;
    private KeRui.BLL.CmsComment bllCmsComment = new KeRui.BLL.CmsComment();
    private ManageErrMsg nsb = new ManageErrMsg();
    protected KeRui.BLL.SysApp bllSysApp = new KeRui.BLL.SysApp();
    protected KeRui.BLL.CmsSite bllCmsSite = new KeRui.BLL.CmsSite();
    protected int AppID = PageRequest.GetInt("AppID",0);
    protected int SiteID = PageRequest.GetInt("siteID",-1);

    protected int NodeID = PageRequest.GetInt("nodeID",-1);
    protected int ContentID = PageRequest.GetInt("ContentID", -1);

    #region 分页
    //基础
    public List<KeRui.Model.AdminLog> list;
    public int PageSize = 15;                               //每页数量
    public int PageIndex = PageRequest.GetInt("page", 1);   //请求的页码
    public int PageCS = PageRequest.GetInt("cs", -1);       //记录总数
    public int PageCount = 0;                               //总页数
    public string PageShow = "";                            //分页显示
    ///参数
    #endregion 分页

    protected void Page_Load(object sender, EventArgs e)
    {
        ManageHelper.CheckAdminLogin();//登陆判断
        listCmsComment = bllCmsComment.GetList(PageSize, PageIndex, 0, 0, SiteID, AppID, NodeID, ContentID);
        //总数
        if (PageCS == -1)
            PageCS = bllCmsComment.GetCount( 0, 0, SiteID, AppID, NodeID, ContentID);
        //总页数
        if (PageCS % PageSize == 0)
            PageCount = PageCS / PageSize;
        else
            PageCount = PageCS / PageSize + 1;
        //分页显示
        PageShow = ManageHelper.showSplitPage("CommentList.aspx?cs=" + PageCS.ToString() + "&page={0}&AppID="+AppID+"&SiteID="+SiteID+"", PageIndex, PageSize, PageCS);
        switch (ManageHelper.PageAct())
        {
            case "del":
                Del();
                break;
            default:
                break;
        }
    }

    private void Del()
    {
        int commentID = PageRequest.GetInt("Id", -1);
        if (commentID == -1)
        {
            nsb.AddErr("Error1"); nsb.ChkErr();
        }
        bllCmsComment.Delete(commentID);
        Response.Redirect("CommentList.aspx?sucmsg=删除成功。");
    }
}
